package sv.gob.mh.dgii.eda.dec.commons;

import java.util.Date;

import org.joda.time.DateTime;

public enum Formularios {

    RENTA(4, "F11"), IVA(3, "F07"), PAGO_CTA(5, "F14");
    private final Integer codigo;
    private final String siglas;

    Formularios(Integer codigo, String siglas) {
        this.codigo = codigo;
        this.siglas = siglas;

    }

    public Integer getCodigo() {
        return this.codigo;

    }

    public String getSiglas() {
        return this.siglas;
    }

    public Date getDefaulPeriod() {
        if (this.codigo.equals(IVA.getCodigo())) {
            DateTime now = new DateTime();
            DateTime pastMonth = now.minusMonths(1);
            DateTime firstDayPastMonth = new DateTime(pastMonth.getYear(),
                    pastMonth.getMonthOfYear(), 1, 12, 0, 0, 0);
            return firstDayPastMonth.toDate();

        } else {
            DateTime now = new DateTime();
            DateTime pastYear = now.minusYears(1);
            DateTime firstDayPastYear = new DateTime(pastYear.getYear(), 1, 1,
                    12, 0, 0, 0);
            return firstDayPastYear.toDate();
        }
    }
}
